/**
* Created by fengling on 2016/5/10.
*/
//var httpurl = 'http://218.66.59.169:4203';
    // var httpurl = 'https://crmapp.swhysc.com/webtalk';
//var httpurl = 'http://58.247.5.172:8091';
// var httpurl = 'https://crmapp.swhysc.com/webtalk';
var httpurl = 'http://localhost:8090/webtalk';
var httpurl=base;
//var httpurl = 'http://192.168.0.33:8091';
//var httpurl = 'http://218.85.80.117:3303';
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
function backpage(){
    var fromurl = getParameter('fromurl');
    if(fromurl!=null||fromurl!=''){
        window.location.href=decodeURIComponent(fromurl)
    }
    return false;
}
function showmessage(message){
    layer.open({
        content: message,
        style: 'background-color:RGBA(0,0,0,.5); color:#fff; border:none;',
        time: 2
    });
}
/*
 获取参数
 */
function getParameter(param)
{
    var query = window.location.search;//获取URL地址中？后的所有字符
    var iLen = param.length;//获取你的参数名称长度
    var iStart = query.indexOf(param);//获取你该参数名称的其实索引
    if (iStart == -1)//-1为没有该参数
        return "";
    iStart += iLen + 1;
    var iEnd = query.indexOf("&", iStart);//获取第二个参数的其实索引
    if (iEnd == -1)//只有一个参数
        return query.substring(iStart);//获取单个参数的参数值
    return query.substring(iStart, iEnd);//获取第二个参数的值
}
function IsNum(s)
{
    if(s!=null){
        var r,re;
        re = /\d*/i; //\d表示数字,*表示匹配多个数字
        r = s.match(re);
        return (r==s)?true:false;
    }
    return false;
}

Date.prototype.Format = function(fmt) { // author: meizz
    var o = {
        "M+" : this.getMonth() + 1, // 月份
        "d+" : this.getDate(), // 日
        "h+" : this.getHours(), // 小时
        "m+" : this.getMinutes(), // 分
        "s+" : this.getSeconds(), // 秒
        "q+" : Math.floor((this.getMonth() + 3) / 3), // 季度
        "S" : this.getMilliseconds()
        // 毫秒
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "")
            .substr(4 - RegExp.$1.length));
    for ( var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k])
                : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}


function CheckUrl(str) {
    var RegUrl = new RegExp();
    //RegUrl.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
    //RegUrl.compile("https|http|ftp|rtsp|mms+://:[A-Za-z0-9_]+(\\.[A-Za-z0-9_]+)+");
    RegUrl.compile("^[https|http|ftp|rtsp|mms]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]");
    if (!RegUrl.test(str)) {
        return false;
    }
    return true;
}
function jumpPage(page,params){
    if (typeof page == "undefined" || page == "")
        return;
    // 动态添加参数
    page=page+'?';
    if (typeof params != "undefined" && !$.isEmptyObject(params)) {
        $.each(params, function(key, value) {
                if (typeof value != "undefined" && value != "") {
                    page=page+key+'='+value+'&';
                }
            });
    }
    window.location.href=page.substring(0,page.length-1);
}
function nvl(value,defaultvalue){
    if(value==null||value=='undefined'||value==''){
        value=defaultvalue;
    }
    return value;
}
function encode64(input){return input;
    input = escape(input);
    var output = "";
    var chr1, chr2, chr3 = "";
    var enc1, enc2, enc3, enc4 = "";
    var i = 0;

    do {
        chr1 = input.charCodeAt(i++);
        chr2 = input.charCodeAt(i++);
        chr3 = input.charCodeAt(i++);

        enc1 = chr1 >> 2;
        enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
        enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
        enc4 = chr3 & 63;

        if (isNaN(chr2)) {
            enc3 = enc4 = 64;
        } else if (isNaN(chr3)) {
            enc4 = 64;
        }

        output = output +
        keyStr.charAt(enc1) +
        keyStr.charAt(enc2) +
        keyStr.charAt(enc3) +
        keyStr.charAt(enc4);
        chr1 = chr2 = chr3 = "";
        enc1 = enc2 = enc3 = enc4 = "";
    } while (i < input.length);

    return output;
}
function decode64(input){return input;
    var output = "";
    var chr1, chr2, chr3 = "";
    var enc1, enc2, enc3, enc4 = "";
    var i = 0;

    // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
    var base64test = /[^A-Za-z0-9\+\/\=]/g;
    if (base64test.exec(input)) {
    }
    input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

    do {
        enc1 = keyStr.indexOf(input.charAt(i++));
        enc2 = keyStr.indexOf(input.charAt(i++));
        enc3 = keyStr.indexOf(input.charAt(i++));
        enc4 = keyStr.indexOf(input.charAt(i++));

        chr1 = (enc1 << 2) | (enc2 >> 4);
        chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
        chr3 = ((enc3 & 3) << 6) | enc4;

        output = output + String.fromCharCode(chr1);

        if (enc3 != 64) {
            output = output + String.fromCharCode(chr2);
        }
        if (enc4 != 64) {
            output = output + String.fromCharCode(chr3);
        }

        chr1 = chr2 = chr3 = "";
        enc1 = enc2 = enc3 = enc4 = "";

    } while (i < input.length);

    return unescape(output);
}